package com.jlcindia.hibernate;
import java.util.*;

import org.hibernate.*;
public class Lab5Client 
{
	public static void main(String args[])
	{
		Transaction tx=null;
		try
		{
			SessionFactory sf=HibernateUtil.getSessionFactory();
			Session session=sf.openSession();
			tx=session.beginTransaction();
			String cous[]= {"Java","JDBC","JSP"};
			List<String> ems = new ArrayList<String>();
			ems.add("aa@jlc");
			ems.add("bb@jlc");
			ems.add("cc@jlc");
			List<Integer> maks = new ArrayList<Integer>();
			maks.add(new Integer(100));
			maks.add(new Integer(99));
			maks.add(new Integer(100));
			Set<Long> phs = new HashSet<Long>();
			phs.add(new Long(1111));
			phs.add(new Long(2222));
			phs.add(new Long(3333));
			Map<String,Long> refs = new HashMap<String, Long>();
			refs.put("aaa", new Long(1111));
			refs.put("bbb", new Long(2222));
			refs.put("ccc", new Long(3333));
			Student stu = new Student("sri","10-10-10","M.sc",cous,ems,maks,phs,refs);
			
			Integer in=(Integer)session.save(stu);
			int cid=in.intValue();
			System.out.println("cid:"+cid);
			tx.commit();
		}
		catch (Exception e) 
		{
			e.printStackTrace();
			if(tx!=null)
				tx.rollback();
		}
	}
}
